package com.hsource.doctorcenter.controller;

import com.hsource.common.utils.CommonResp;
import com.hsource.common.utils.resultUtils.controller.BaseController;
import com.hsource.doctorcenter.domain.version.ApkVersion;
import com.hsource.doctorcenter.service.version.IApkVersionService;
import com.hsource.doctorcenter.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yangYang
 * @version 1.0
 * @date 2020/10/28 11:52
 * @describe
 */
@Slf4j
@Controller
@RequestMapping("/apkVersion")
public class ApkVersionController extends BaseController {

    @Autowired
    private IApkVersionService apkVersionService;


    /**
     * 获取版本信息
     * @param version
     * @param channel
     * @return
     */
    @PostMapping("/checkVersion")
    @ResponseBody
    public CommonResp getcheckVersion(String version, String channel) {
        ApkVersion apkVersion = apkVersionService.checkVersion(version, channel);
        Map<String,Object> map=new HashMap<>();
        if(StringUtils.isNotNull(apkVersion)){
            map.put("version",apkVersion);
            return success(map);
        }
        return failed("无当前渠道版本信息");
    }
}
